package com.atguigu.gulimall.order.vo;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public class OrderConfirmVo {
    //        所有收货地址
    @Setter @Getter
    List<MemberAddressVo> address;
    //        所有选中的购物项
    @Setter @Getter
    List<OrderItemVo> items;
    //发票信息。。。略

//        优惠券
@Setter @Getter
 Integer integration;
    @Setter @Getter
Map<Long,Boolean> stocks ;
//防重令牌
    @Setter @Getter
String orderTooken ;
  //  BigDecimal total ;//订单总额

    public Integer getCount(){
        int i=0 ;
        if(items!=null){
            for (OrderItemVo item : items) {
                i+=item.getCount() ;
            }
        }
        return i ;
    }
    public BigDecimal getTotal() {
        BigDecimal sum  = new BigDecimal("0");
        if(items!=null){
            for (OrderItemVo item : items) {
                BigDecimal multiply = item.getPrice().multiply(new BigDecimal(item.getCount().toString()));
                sum = sum.add(multiply);
            }
        }
        return sum;
    }

    //BigDecimal payPrice ;//应付价格

    public BigDecimal getPayPrice() {
        return getTotal();
    }
}
